<template>
    <section>
      <img src="../../assets/carlist/carResult.png" class="banner">
      <div style="box-shadow: 0px 5px 10px rgba(194,194,194,.2);">
        <yd-cell-item arrow type="label">
          <span slot="left">保险公司</span>
          <select slot="right" style="margin-left: .1rem;color: #555;" v-model="input1">
            <option value="">请选择保险公司</option>
            <option value="人保">人保</option>
            <option value="浙商">浙商</option>
            <option value="安邦">安邦</option>
            <option value="中华">中华</option>
            <option value="民安">民安</option>
            <option value="渤海">渤海</option>
            <option value="富德">富德</option>
            <option value="富邦">富邦</option>
            <option value="长安">长安</option>
            <option value="国泰">国泰</option>
            <option value="泰山">泰山</option>
            <option value="信达">信达</option>
            <option value="锦泰">锦泰</option>
            <option value="安诚">安诚</option>
            <option value="众诚">众诚</option>
            <option value="紫金">紫金</option>
            <option value="英大">英大</option>
            <option value="平安">平安</option>
            <option value="太平洋">太平洋</option>
            <option value="阳光">阳光</option>
            <option value="安盛天平">安盛天平</option>
            <option value="人寿">人寿</option>
            <option value="太平">太平</option>
            <option value="永诚">永诚</option>
            <option value="大地">大地</option>
            <option value="华安">华安</option>
            <option value="天安">天安</option>
            <option value="永安">永安</option>
            <option value="都邦">都邦</option>
            <option value="中银">中银</option>
            <option value="鼎和">鼎和</option>
          </select>
        </yd-cell-item>
        <yd-cell-item>
          <span slot="left">保单号</span>
          <yd-input  slot="right" v-model="input2"  required :show-required-icon="false" :show-success-icon="false" :show-error-icon="false"  placeholder="请输入保单号" style="margin-left: 0.38rem;
"></yd-input>
        </yd-cell-item>
        <yd-cell-item>
          <span slot="left">车牌号</span>
          <yd-input slot="right" v-model="input3"  required :show-required-icon="false" :show-success-icon="false" :show-error-icon="false"  placeholder="格式：苏A12345" style="margin-left: 0.38rem;
"></yd-input>
        </yd-cell-item>
        <yd-cell-item>
          <span slot="left">证件号</span>
          <yd-input slot="right" v-model="input4"  required :show-required-icon="false" :show-success-icon="false" :show-error-icon="false"  placeholder="请输入身份证号或企业税号" style="margin-left: 0.38rem;
"></yd-input>
        </yd-cell-item>
      </div>
      <div  class="footer_pos">
        <div class="foot_left">
          <span>需付金额：</span><span style="color: red;font-weight: bold; ">￥{{price}}</span>
        </div>
        <div class="foot_right" @click="show2()">
          立即验证
        </div>
      </div>
      <payPart :show-wrap="iswrap" :need-param="param" :product-title="title" :product-price="price" :api-logo="apilogo"></payPart>
    </section>
</template>

<script>
  import payPart from '@/components/api/pay_part';
    export default {
        name: "carPolicy",
        data(){
          return{
            input1:'',
            input2:'',
            input3:'',
            input4:'',
            price:'',
            apilogo:'',
            iswrap:false,
            param:{},
            title:'车辆保单信息查询',
          }
        },
      components:{
        payPart
      },
      methods:{
        show2(){
          const that = this;
          if(this.input1 == ''){
            this.$dialog.notify({
              mes: '请选择保险公司',
              timeout: 1500,
            });
            return;
          }
          if(this.input2 == ''){
            this.$dialog.notify({
              mes: '请输入保单号',
              timeout: 1500,
            });
            return;
          }
          if(this.input3 == ''){
            this.$dialog.notify({
              mes: '请输入车牌号',
              timeout: 1500,
            });
            return;
          }
          if(this.input4 == ''){
            this.$dialog.notify({
              mes: '请输入证件号',
              timeout: 1500,
            });
            return;
          }

          let redirectUrl = this.$route.path;
          this.$ajax.post(window.g.apiUrl+'/user/isLog.do')
            .then((response)=> {
              if (response.data.code != 200) {
                this.$dialog.notify({
                  mes: '您还未登录，将为您跳转到登录页面',
                  timeout: 3000,
                  callback: () => {
                    let obj = {};
                    obj.com = that.input1;
                    obj.baodan = that.input2;
                    obj.carCode = that.input3;
                    obj.code = that.input4;
                    obj.url = redirectUrl;
                    sessionStorage.setItem('redirectUrl',JSON.stringify(obj));
                    that.$router.push('/login');
                  }
                });
              } else {
                that.param.com = that.input1;
                that.param.baodan = that.input2;
                that.param.carCode = that.input3;
                that.param.code = that.input4;
                that.param.pid = '29';
                that.iswrap = !that.iswrap;
              }
            }).catch(()=>{
          })

        }
      },
      created(){
        let that = this;
        let redirectUrl = JSON.parse(sessionStorage.getItem('redirectUrl'));
        if(redirectUrl != null){
          this.input1 = redirectUrl.com;
          this.input2 = redirectUrl.baodan;
          this.input3 = redirectUrl.carCode;
          this.input4 = redirectUrl.code;
          sessionStorage.removeItem('redirectUrl');
        }
        this.$ajax.post(window.g.apiUrl+'/alipay/getProduct.do',JSON.stringify({
          type:'B',
        })).then((response)=>{
          if(response.data.code == 200){
            let arr = response.data.data;
            for(var i = 0;i<arr.length;i++){
              if(arr[i].id == '29'){
                that.price = arr[i].price;
                that.apilogo = arr[i].iconurl;
              }
            }
            // that.pid = response.data.data[1].id;
          }else{
            that.$dialog.notify({
              mes: '信息获取超时，请稍后重试',
              timeout: 1500,
            });
          }


        }).catch(()=>{
        })
      },
    }
</script>

<style scoped>
.banner{
  width: 100%;
  display: block;
}
.footer_pos{
  width: 100%;
  height: 1rem;
  background: #F5F5F5;
  position: fixed;
  bottom: 0;
  display: flex;
}
.foot_left{
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
}
.foot_right{
  width: 2.5rem;
  height: 1rem;
  background: #E72A26;
  color: #fff;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
